﻿<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var="basePath" value="${pageContext.request.contextPath}" scope="application" />
<!DOCTYPE html>
<html>
<head>
<title>执行sql-订正库表</title>
<script src="${basePath}/static/js/jquery-2.1.4.min.js"></script>
<script src="${basePath}/static/js/bootstrap.min.js"></script>
<script src="${basePath}/static/js/jquery-confirm.min.js" charset="UTF-8"></script>
<link href="${basePath}/static/css/bootstrap.min.css" rel="stylesheet" />
<link href="${basePath}/static/css/jquery-confirm.min.css" rel="stylesheet" />
<style type="text/css">
.vertical-center {
	position: absolute;
	top: 30%;
	left: 50%;
	transform: translate(-50%, -50%);
}
</style>
</head>
<body>
	<div class="container">
		<div class="row clearfix">
			<div class="col-md-3 column vertical-center">
				<div class="row clearfix">
					<div class="col-md-12 column">
						<h4 class="text-center text-warning">订正库表</h4>
					</div>
				</div>
				<div class="form-group" >
					<label>选择sql类型</label><br>
					<select id="type" style="width:100%;height:30px;">
						<option value="1">单纯执行下方sql</option>
						<option value="all">变更所有表结构</option>
					</select>
				</div>
				<div class="form-group" style="margin-top: 30px;">
					<textarea id="sql" style="width:100%;height:200px;"></textarea>
				</div>
				<button type="button" onclick="javascript:submit();" class="btn btn-block btn-large btn-info">执行</button>
			</div>
		</div>
	</div>
</body>
</html>
<script type="text/javascript">
	function submit() {
		var sql = $("#sql").val();
		var type = $("#type").val();
		$.post("${basePath}/ddl/excuteSql", {"sql" : sql,"type" : type}, function(result) {
			result = eval('(' + result + ')'); 
			if (result.code == 200) {
				$.alert("执行成功");
			} else {
				$.alert("执行失败," + result.msg);
			}
		});
	}
	
</script>
